require "set"

module ::Wondercap
module Deployment
module NameFilters
   
  class TagsFilter
    def call(names, base_config)
      tags = base_config.fetch(:tags, "").split(",").map { |tag| tag.to_sym }.to_set
      names.delete_if do |name|
        !tags.subset?(base_config.mc.find_configuration(name).tags.to_set)
      end
    end     
  end
    
end
end
end

define_name_filter :tags, Wondercap::Deployment::NameFilters::TagsFilter.new
